package com.honeywen.mymvc.test;



/**
 * @author wangwei
 * @date 2019/5/9
 */
public class ReentrantLockDemo {

    public static void main(String[] args) {
        MyData myData = new MyData();
        for (int i = 1; i <= 20 ; i++) {

            new Thread(() -> {
                for (int j = 1; j < 1000; j++) {
                    myData.add();
                }

            }, String.valueOf(i)).start();

        }

        while (Thread.activeCount() > 1) {
            Thread.yield();
        }
        System.out.println("结果: " + myData.num);
    }

}
